package com.isoft.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.isoft.dao.Luggagedao;
import com.isoft.entity.Luggage;
import com.isoft.entity.PageBean;
import com.isoft.service.ILuggageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LuggageService implements ILuggageService {
    @Autowired
    Luggagedao luggagedao;
    @Override
    public PageBean getAll(Integer page, Integer pageSize) {
        //1.设置分页参数
        PageHelper.startPage(page, pageSize);
        //2.执行查询
        List<Luggage> luggageList = luggagedao.getAll();
        Page<Luggage> p = (Page<Luggage>) luggageList;
        //3.封装PageBean对象
        PageBean pageBean = new PageBean((int) p.getTotal(), p.getResult());
        return pageBean;
    }

    @Override
    public Boolean updateLug(Luggage luggage) {
        return luggagedao.updateLug(luggage)>0;
    }
}
